import { Children } from 'react'
import { Link, BrowserRouter, Routes, Route ,useRoutes} from 'react-router-dom'
import Layout from '../Layout/Layout'
import Hot from '../pages/Hot/Hot'
import Write from '../pages/Write/Write'

const NotFound = () => <div>not found</div>

const routes=[
    {
        path:'/main',
        element:<Layout></Layout>,
        children:[
            {
                index:true,
                element:<Hot></Hot>
            },
            {
                path:'write',
                element:<Write></Write>
            }
        ]
    },
    {
        path:'*',
        element:<NotFound></NotFound>
    }
]
function WrapperRoutes(){
    // 识别当前的url，返回对应的组件<Layout />
    let element=useRoutes(routes)
    return element
}

export default WrapperRoutes